<?php
if (!defined('sugarEntry') || !sugarEntry)
    die('Not A Valid Entry Point');

function get_flags_query($params) {
	require_once('modules/Tasks/Task.php');
	$task = new Task();
	$task->retrieve($params['task_id']);

	$return_array['select'] = " SELECT edanz_flags.id  ";
	$return_array['from'] = " FROM edanz_flags ";
	$return_array['join'] = " LEFT JOIN edanz_deliverables_flags ON edanz_deliverables_flags.flags_id = edanz_flags.id and edanz_flags.deleted = 0 and edanz_deliverables_flags.deleted = 0 ";
	$return_array['where'] = " edanz_deliverables_flags.deliverables_id =  '" . $task->deliverable_id . "'";
	return $return_array;
}

function get_feedback_query($params) {
	require_once('modules/Tasks/Task.php');
	$task = new Task();
	$task->retrieve($params['task_id']);

	$return_array['select'] = " SELECT edanz_feedback.id ";
	$return_array['from'] = " FROM edanz_feedback ";
	$return_array['join'] = "";
	$return_array['where'] = " edanz_feedback.deliverable_id = '" . $task->deliverable_id . "' and edanz_feedback.deleted = 0 ";

	return $return_array;
}

function get_task_query($params) {
	require_once('modules/Tasks/Task.php');
	$task = new Task();
	$task->retrieve($params['task_id']);

	$return_array['select'] = " SELECT tasks.id ";
	$return_array['from'] = " FROM tasks ";
	$return_array['join'] = "";
	$return_array['where'] = " tasks.deliverable_id = '" . $task->deliverable_id . "' and tasks.id != '".$task->id."' and tasks.deleted = 0 ";

	return $return_array;
}

function get_document_query($params) {
	require_once('modules/Tasks/Task.php');
	$task = new Task();
	$task->retrieve($params['task_id']);

	$return_array['select'] = " SELECT documents.id ";
	$return_array['from'] = " FROM documents ";
	$return_array['join'] = " LEFT JOIN edanz_documents_deliverables ON edanz_documents_deliverables.documents_id = documents.id and documents.deleted = 0 and edanz_documents_deliverables.deleted = 0 ";
	$return_array['where'] = " edanz_documents_deliverables.deliverable_id = '" . $task->deliverable_id . "'";
	return $return_array;
}

function get_authorpreferences_query($params) {
	require_once('modules/Tasks/Task.php');
	$task = new Task();
	$task->retrieve($params['task_id']);

	$return_array['select'] = " SELECT edanz_authorpreferences.id ";
	$return_array['from'] = " FROM edanz_authorpreferences ";
	$return_array['join'] = " LEFT JOIN edanz_deliverables_authorpreferences ON edanz_deliverables_authorpreferences.authorpreferences_id=edanz_authorpreferences.id and edanz_authorpreferences.deleted = 0 and edanz_deliverables_authorpreferences.deleted = 0 ";
	$return_array['where'] = " edanz_deliverables_authorpreferences.deliverables_id = '" . $task->deliverable_id . "'";
	return $return_array;
}

function get_communications_query($params) {
	require_once('modules/Tasks/Task.php');
	$task = new Task();
	$task->retrieve($params['task_id']);

	$return_array['select'] = " SELECT edanz_communications.id ";
	$return_array['from'] = " FROM edanz_communications ";
	$return_array['join'] = " LEFT JOIN edanz_deliverables_communications ON edanz_deliverables_communications.communications_id = edanz_communications.id and edanz_communications.deleted = 0 and edanz_deliverables_communications.deleted = 0";
	$return_array['where'] = " edanz_deliverables_communications.deliverables_id = '" . $task->deliverable_id . "'";
	return $return_array;
}


?>
